from datetime import timedelta
from redis import StrictRedis


class Config(object):
    DEBUG = True  # 设置调试模式
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/info177'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = '6379'
    SESSION_TYPE = 'redis'  # 配置session存储形式
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True  # 设置sessionid进行加密
    SECRET_KEY = 'Vj77GuiyWtX9lRv1jN9PfCEO0D0cHU/1sVZBD6EhNxGzyCdbSdDZg77qP14qjfCH'
    PERMANENT_SESSION_LIFETIME = timedelta(days=7)
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True  # 设置请求结束自动提交


class DevelopmentConfig(Config):  # 开发环境
    DEBUG = True


class ProductConfig(Config):  # 生产环境
    DEBUG = False

config_dict = {
    'dev': DevelopmentConfig,
    'pro': ProductConfig
}